<template>
  <div class="goods-desc">
    <my-header titleName="图文介绍"></my-header>
    <!-- 1. 渲染页面 -->
    <h3 class="desc-title">{{imgInfo.title}}</h3>
    <div class="desc-content" v-html="imgInfo.content"></div>
  </div>
</template>
<script>
import { getDesc } from '@/api'
import myHeader from '@/components/myHeader'
export default {
  components: {
    myHeader
  },
  data () {
    return {
      // 获取路由地址上的id
      id: this.$route.params.id,
      // 存放图文介绍的对象
      imgInfo: {}
    }
  },
  created () {
    // 1.2 调用初始化图文介绍方法
    this.initInfo()
  },
  methods: {
    // 1.1 初始化图文介绍方法
    initInfo () {
      getDesc(this.id).then(res => {
        // console.log(res)
        this.imgInfo = res.message[0]
      })
    }
  }
}
</script>

<style lang="less" scoped>
img {
    display: block;
}
.goods-desc {
  margin-top: 50px;
  h3 {
    font-weight: bold;
    color: #26a2ff;
    font-size: 16px;
    margin-bottom: 5px;
  }
  .desc-content {
    font-size: 14px;
  }
}
</style>
